import 'package:audioplayers/audioplayers.dart';

import 'dart:async';

class AudioPlayerHelper {
  AudioPlayerHelper._();

  static final AudioPlayerHelper _manager = AudioPlayerHelper._();

  factory AudioPlayerHelper() {
    return _manager;
  }

  late AudioPlayer player;

  Future init() async {
    player = AudioPlayer();
  }

  Future play(String path) async {
    await stop();

    if (path.isNotEmpty) {
      await player.play(AssetSource(path));
    }
  }

  Future pause() async {
    await player.pause();
  }

  Future stop() async {

    await player.stop();
  }
}